/** <!--------------------------------------------------------------------------------------------->
 * @file RevGraphBranchMap.h
 *
 * GSvn - A Graphical Client for SVN
 * Copyright (C) 2012  Karl Krach, gsvn@bluespirit.la
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 <!---------------------------------------------------------------------------------------------> */


#ifndef REVGRAPHBRANCHMAP_H
#define REVGRAPHBRANCHMAP_H

#include <QWidget>


// -- includes --
#include <QMap>
#include "RevGraphBranch.h"
#include <QDebug>
#include "RevGraphBranchLink.h"

// --- forward declarations ---
// --- namespaces ---
// --- defines ---


/** <!--------------------------------------------------------------------------------------------->
 * Map to store the revision graphs
 *
 * @author	Karl Krach, <gsvn@bluespirit.la>
 * @since	2012-02-11
 <!---------------------------------------------------------------------------------------------> */
class RevGraphBranchMap
{
	/* Con-/Destructors */
public:

	/** <!----------------------------------------------------------------------------------------->
	 * Creates the RevGraphBranchMap object
	 <!-----------------------------------------------------------------------------------------> */
	RevGraphBranchMap();

	/** <!----------------------------------------------------------------------------------------->
	 * Deletes the RevGraphBranchMap object
	 <!-----------------------------------------------------------------------------------------> */
	virtual ~RevGraphBranchMap();


	/* Override QMap */
public:

	/** <!----------------------------------------------------------------------------------------->
	 * Returns true if the given branch index is contained by the map
	 <!-----------------------------------------------------------------------------------------> */
	bool contains( BranchIndex iBranchIndex ) { return m_aMap.contains( iBranchIndex ); }

	/** <!----------------------------------------------------------------------------------------->
	 * Inserts the given graph item to the map
	 <!-----------------------------------------------------------------------------------------> */
	RevGraphBranchLink insert( BranchIndex iBranchIndex, RevGraphBranch* pGraphBranch )
	{
		return RevGraphBranchLink( m_aMap.insert( iBranchIndex, pGraphBranch ), &m_aMap );
	}

	/** <!----------------------------------------------------------------------------------------->
	 * Returns the graph item with the given branch index. Call contains() before!
	 <!-----------------------------------------------------------------------------------------> */
	RevGraphBranch* get( BranchIndex iBranchIndex ) { return m_aMap.value( iBranchIndex ); }


	/* Members */
private:

	/** <!----------------------------------------------------------------------------------------->
	 * Map object which stores the mapping
	 <!-----------------------------------------------------------------------------------------> */
	QMap< BranchIndex, RevGraphBranch* > m_aMap;
};

#endif // REVGRAPHBRANCHMAP_H
